 /**
 * Brightness
 * by Rusty Robison, enhanced by Pierre Berger
 *
 * Brightness is the relative lightness or darkness of a color.
 * Move the cursor vertically over each bar to alter its brightness.
 *
 * Updated 8 May 2007
 */
 
int barWidth = 5;
int[] brightness;

void setup()
{
  size(200, 200);
  colorMode(HSB, 180, height, height); 
  brightness = new int[width/barWidth];
  fill(0,0,0);
  rect(0,0, 200,200);
}

void draw()
{
  int j = 0, xdom;
  for (int i = 0; i <= (width-barWidth); i += barWidth) { 
    noStroke();
    if ((mouseX > i) && (mouseX < i+barWidth)) {
      brightness[j] = mouseY;
                                               }
    fill( (int) random(180), (int) random(height), brightness[j]);
    rect(i, 0, barWidth, height/2); 
    fill(i,180, brightness[j]);
    xdom = (int) random(6);
    switch(xdom) {
   case 0:  ellipse(i,(3*height)/4, barWidth, height/2); break;
   case 1:  rect(i, height/2, barWidth, height);        break;
   case 2:  triangle( (int) random(200), (int)random(200), (int) random(200), (int)random(200), (int) random(200), (int)random(200) );
             break;
   case 3:  line(0,0,200,200); break;
   case 4: arc(100,100, 20,20,20,20);  break;
   case 5: point (3,3); break ;
   //  case 6: quad (10, 10,   190, 10,   190,     190, 1O,    190); break; 
   case 6: quad (0,   0, width,  0, width,  height,  0, height); break;
   default : break;
                  }
   
    j++;
  }
} 